package com.taotao.tools.validate.annotations;

import com.taotao.tools.validate.validator.MustEqualsValidator;

import javax.validation.Constraint;
import javax.validation.Payload;
import java.lang.annotation.Documented;
import java.lang.annotation.Inherited;
import java.lang.annotation.Repeatable;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;


/**
 * 与某个字段相等
 *
 * @author youbeiwuhuan
 */
@Inherited
@Target({TYPE})
@Retention(RUNTIME)
@Repeatable(MustEquals.List.class)
@Constraint(validatedBy = {MustEqualsValidator.class})
@Documented
public @interface MustEquals {

    /**
     * 指定相等的字段名称
     *
     * @return
     */
    String fieldName1();

    String fieldName2();

    String message() default "";

    Class<?>[] groups() default {};

    Class<? extends Payload>[] payload() default {};


    @Inherited
    @Target({TYPE})
    @Retention(RUNTIME)
    @Documented
    @interface List {
        MustEquals[] value();
    }

}
